package org.dppc.contact.m8;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;

@XStreamAlias("IMElement")
public class IMElement {
	@XStreamAlias("IsPrimary")
	@XStreamAsAttribute
	private int isPrimary;
	
	@XStreamAlias("Value")
	@XStreamAsAttribute
	private String value;
	
	@XStreamAlias("Type")
	@XStreamAsAttribute
	private int type;



	public IMElement(int isPrimary, String value, int type) {
		super();
		this.isPrimary = isPrimary;
		this.value = value;
		this.type = type;
	}

	public int getIsPrimary() {
		return isPrimary;
	}

	public void setIsPrimary(int isPrimary) {
		this.isPrimary = isPrimary;
	}



	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
	
	public static void main(String[] args){
		XStream xStream = new XStream();
		xStream.processAnnotations(IMElement.class);
		try {
			InputStream xmlReader = new FileInputStream(new File("d:\\IMElement.xml"));
			IMElement im = (IMElement) xStream.fromXML(xmlReader);
			System.out.println(im.isPrimary + im.value + im.type);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}
	
}
